<?php
include_once './inc/config_inc.php';
include_once './inc/mysql_inc.php';
include_once './inc/tool_inc.php';
include_once './inc/page_inc.php';
$link=connect();
$user_id=is_login($link);
$is_manage_login=is_manage_login($link);
$query="select count(*) from content";
$count_all=num($link, $query);

$template['title']='展示留言页';
$template['css']=array('style/public.css','style/words.css');
?>
<?php include 'inc/header_inc.php';?>

<!--展示留言-->
<div id="word">
	<a href="index.php" style="font-size: 17px;font-family: 微软雅黑;color: black;">首页</a> &gt; <span style="font-size: 17px;font-family: 微软雅黑;margin-bottom: 20px">留言展示</span>
	<a href="publish.php" style="width: 70px;height: 30px;line-height: 30px; text-align: center;border-radius: 2px;color: white;background-color: black;float: right;margin-right: 30px;cursor: pointer;margin-bottom: 20px;">我要留言</a>
	<div class="pages">
			<?php 
			$page=page($count_all,5);
			echo $page['html'];
			?>
	</div>

	<?php 
	$query="select content.id,content.create_time,content.user_id,user.photo,user.name username,content.times,content.content from content,user where  content.user_id=user.id order by content.create_time desc {$page['limit']}";
	$result=execute($link,$query);
	$query="update content set times=times+1";
	execute($link,$query);
	while($data=mysqli_fetch_assoc($result)){
		$data['times']=$data['times']+1;
		$data['content']=htmlspecialchars($data['content']);
	?>
		<div class="yu">
			<img src="<?php if($data['photo']!=''){echo $data['photo'];}else{echo 'style/11.jpg';}?>" >
			<div class="yu1" style="width: 400px;"><?php echo $data['content'] ?></div>
			<p class="yu2" style="width: 400px;">发布：<?php echo $data['create_time'] ?>&nbsp;&nbsp;&nbsp;&nbsp;浏览：<?php echo $data['times']?>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $data['username']?>&nbsp;&nbsp;&nbsp;
				<?php 
				if(check_user($user_id,$data['user_id'],$is_manage_login)){
					$url=urlencode("content_delete.php?id={$data['id']}");
					$return_url=urlencode($_SERVER['REQUEST_URI']);
					$message="你真的要删除留言吗？";
					$delete_url="confirm.php?url={$url}&return_url={$return_url}&message={$message}";
					echo "<span><a href='content_update.php?id={$data['id']}'>编辑</a> <a href='{$delete_url}'>删除</a></span>";
				}
				?>
				
			</p>
		</div>
	<?php } ?>
</div>

<?php include 'inc/footer_inc.php';?>